home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 893 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.0 KB

  1. Path: engnews1.Eng.Sun.COM!taumet!clamage
  2. From: "Wil Evers" <wil@ittpub.nl>
  3. Newsgroups: comp.std.c++
  4. Subject: Re: Quick questions
  5. Date: 28 Mar 1996 15:56:16 GMT
  6. Organization: Sun Microsystems Inc., Mountain View, CA
  7. Approved: clamage@eng.sun.com (comp.std.c++)
  8. Message-ID: <009A0046789FF2A0.3D60EEDA@ittpub.nl>
  9. NNTP-Posting-Host: taumet.eng.sun.com
  10. X-Vms-Mail-To: IN%"std-c++@ncar.ucar.edu"
  11. Content-Length: 1238
  12. X-Lines: 28
  13. Originator: clamage@taumet
  14.  
  15. In article <4jajk2$17aq@mule1.mindspring.com> abell@mindspring.com (Andrew
  16. Bell) writes:
  17.  
  18. > clamage@Eng.sun.com (Steve Clamage) wrote:
  19. > [snip]
  20. >
  21. > >I assume you mean a class like
  22. > >     class Short { short val; };
  23. > >with non-virtual member functions added. You can't assume the size and
  24. > >alignment of the class will be the same as its only data member, and
  25. > >no, the standard provides no special support for this special case.
  26. > Seems like if you only have one data member and no virtual functions,
  27. > there's no reason to arbitrarily restrict it to a greater alignment
  28. > level, save maybe to make compiler programmer's lives (and maybe
  29. > debugger programmer's lives) trivially easier.
  30.  
  31. I few weeks ago, I ran into a similar problem (I was wrapping a struct around a
  32. plain character array, which unexpectely changed its alignment), and I did some
  33. enquires on comp.std.c.
  34.  
  35. It turns out some platforms have different optimal pointer representations
  36. depending on the alignment of what's being pointed to. Since you don't need to
  37. define a structure before you declare a pointer to it, assuming all structures
  38. are maximally aligned "just because they're structures" may actually result in
  39. more efficient code on these machines.
  40.  
  41. - Wil
  42.  
  43.  
  44. [ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
  45. [ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
  46. [ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
  47. [ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
  48. [ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
  49.